public abstract class ChainOfResponsibility {

    public static void main(String[] args) {
        ChainOfResponsibility ca = new ChainA();
        ChainOfResponsibility cb = new ChainB();
        ChainOfResponsibility cc = new ChainC();
        ca.NextChain = cb;
        cb.NextChain = cc;
        
        ca.show(40);
        ca.show(70);
        ca.show(90);
    }

    public ChainOfResponsibility NextChain;

    public abstract void show(int level);
}

class ChainA extends ChainOfResponsibility {
    @Override
    public void show(int level) {
        if (level < 60) {
            System.out.println(String.format("ChainA.show(%s)", level));
        } else {
            NextChain.show(level);
        }
    }
}

class ChainB extends ChainOfResponsibility {
    @Override
    public void show(int level) {
        if (level < 85) {
            System.out.println(String.format("ChainB.show(%s)", level));
        } else {
            NextChain.show(level);
        }
    }
}

class ChainC extends ChainOfResponsibility {
    @Override
    public void show(int level) {
        System.out.println(String.format("ChainC.show(%s)", level));
    }
}